const {ipcRenderer} = require('electron')

let name = null

ipcRenderer.send('get-name')

ipcRenderer.on('give-name', (event, message) => {
    name = message
    document.getElementById("user_name").innerHTML = "你好，" + message + " ！"
})

ipcRenderer.send('get-history')

ipcRenderer.on('send-history', (event, message) => {
    for (let i = 0; i < message.length; i++) {
        let date = message[i].time
        let info = message[i].disc
        let new_li = document.createElement("li")
        new_li.setAttribute("class", "list-group-item")
        new_li.innerHTML = date + "&nbsp" + "&nbsp" + info
        document.getElementById("record").appendChild(new_li)
    }
})